/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package flames.view;

import com.sun.awt.AWTUtilities;
import flames.images.Colors;
import flames.utils.SwingUtils;

import java.awt.Color;
import java.awt.Point;
import java.awt.event.KeyEvent;

/**
 * @author 10373
 */
public class Login extends javax.swing.JFrame {

    private Point pressedPoint;
    public final Color NORMAL_COLOR = new Color(132, 132, 132);   // #848484
    public final Color ACTIVE_COLOR = new Color(242, 135, 24);    // #f28718

    /**
     * Creates new form NewJFrame
     */
    private Login() {
        this.setUndecorated(true);     // 只有在窗体不可显示时才调用此方法
        this.setResizable(false);   // 设置不可以重置窗口大小
        this.getContentPane().setBackground(Color.white);   // 设置背景颜色

        this.setSize(1230, 810);
        this.setLocationRelativeTo(null);
        initComponents();
        this.RegisterLayeredPane.setVisible(false); // 最初是关闭注册层的

        SwingUtils.beautifyButtonToTransparent(existButton);
        SwingUtils.beautifyButtonToTransparent(loginBtn);
        SwingUtils.beautifyButtonToTransparent(registerBtn);
        SwingUtils.beautifyButtonToTransparent(toRegisterBtn);
        SwingUtils.beautifyButtonToTransparent(toLoginBtn);
        SwingUtils.setBtnBackground(loginBtn, Colors.LOGIN_BTN);
        SwingUtils.setBtnBackground(registerBtn, Colors.LOGIN_BTN);
        SwingUtils.setBtnBackground(toRegisterBtn, Colors.REGISTER_BTN);
        SwingUtils.setBtnBackground(toLoginBtn, Colors.REGISTER_BTN);
        AWTUtilities.setWindowOpacity(this, 0.99f);
        AWTUtilities.setWindowOpaque(this, false);
        head.setOpaque(true);
        head1.setOpaque(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ShadowLayeredPane = new DropShadowPanel(15);
        LoginLayeredPane = new javax.swing.JLayeredPane();
        head = new javax.swing.JLabel();
        logo = new javax.swing.JLabel();
        loginTitle = new javax.swing.JLabel();
        accountLabel = new javax.swing.JLabel();
        accountText = new javax.swing.JTextField();
        pwdLabel = new javax.swing.JLabel();
        pwdText = new javax.swing.JPasswordField();
        loginBtn = new javax.swing.JButton();
        toRegisterBtn = new javax.swing.JButton();
        toRegisterLabel = new javax.swing.JLabel();
        forgetPwdLabel = new javax.swing.JLabel();
        RegisterLayeredPane = new javax.swing.JLayeredPane();
        head1 = new javax.swing.JLabel();
        logo1 = new javax.swing.JLabel();
        loginTitle1 = new javax.swing.JLabel();
        accountLabel1 = new javax.swing.JLabel();
        registerAccountText = new javax.swing.JTextField();
        pwdLabel1 = new javax.swing.JLabel();
        registerPwdText = new javax.swing.JPasswordField();
        registerBtn = new javax.swing.JButton();
        toLoginBtn = new javax.swing.JButton();
        toLoginLabel = new javax.swing.JLabel();
        existButton = new javax.swing.JButton();
        BKG = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                formMouseDragged(evt);
            }
        });
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mainFrameMousePressed(evt);
            }
        });

        ShadowLayeredPane.setBackground(new java.awt.Color(255, 255, 255));

        LoginLayeredPane.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        head.setBackground(new java.awt.Color(248, 249, 249));
        LoginLayeredPane.setLayer(head, javax.swing.JLayeredPane.PALETTE_LAYER);
        LoginLayeredPane.add(head, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 820, 50));

        logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_Flames.png"))); // NOI18N
        LoginLayeredPane.setLayer(logo, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(logo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -2, 60, 50));

        loginTitle.setFont(new java.awt.Font("微软雅黑", 1, 36)); // NOI18N
        loginTitle.setForeground(new java.awt.Color(51, 51, 51));
        loginTitle.setText("登 录");
        LoginLayeredPane.setLayer(loginTitle, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(loginTitle, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 110, 90, 50));

        accountLabel.setFont(new java.awt.Font("微软雅黑", 1, 24)); // NOI18N
        accountLabel.setForeground(new java.awt.Color(51, 51, 51));
        accountLabel.setText("账号");
        LoginLayeredPane.setLayer(accountLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(accountLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 190, 90, 50));

        accountText.setFont(new java.awt.Font("微软雅黑", 0, 22)); // NOI18N
        LoginLayeredPane.setLayer(accountText, javax.swing.JLayeredPane.PALETTE_LAYER);
        LoginLayeredPane.add(accountText, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 240, 570, 60));

        pwdLabel.setFont(new java.awt.Font("微软雅黑", 1, 24)); // NOI18N
        pwdLabel.setForeground(new java.awt.Color(51, 51, 51));
        pwdLabel.setText("密码");
        LoginLayeredPane.setLayer(pwdLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(pwdLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 330, 90, 50));

        pwdText.setFont(new java.awt.Font("微软雅黑", 0, 22)); // NOI18N
        pwdText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                pwdTextKeyPressed(evt);
            }
        });
        LoginLayeredPane.setLayer(pwdText, javax.swing.JLayeredPane.PALETTE_LAYER);
        LoginLayeredPane.add(pwdText, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 380, 570, 60));

        loginBtn.setFont(new java.awt.Font("微软雅黑", 0, 24)); // NOI18N
        loginBtn.setForeground(new java.awt.Color(255, 255, 255));
        loginBtn.setText("登    录");
        loginBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                loginBtnMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                loginBtnMouseExited(evt);
            }
        });
        loginBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginBtnActionPerformed(evt);
            }
        });
        LoginLayeredPane.setLayer(loginBtn, javax.swing.JLayeredPane.PALETTE_LAYER);
        LoginLayeredPane.add(loginBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 500, 570, 60));

        toRegisterBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                toRegisterBtnMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                toRegisterBtnMouseExited(evt);
            }
        });
        toRegisterBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toRegisterBtnActionPerformed(evt);
            }
        });
        LoginLayeredPane.setLayer(toRegisterBtn, javax.swing.JLayeredPane.PALETTE_LAYER);
        LoginLayeredPane.add(toRegisterBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 580, 110, 40));

        toRegisterLabel.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        toRegisterLabel.setForeground(new java.awt.Color(51, 51, 51));
        toRegisterLabel.setText("创建账户");
        LoginLayeredPane.setLayer(toRegisterLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(toRegisterLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 580, 80, 40));

        forgetPwdLabel.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        forgetPwdLabel.setForeground(new java.awt.Color(51, 51, 51));
        forgetPwdLabel.setText("忘记密码？");
        LoginLayeredPane.setLayer(forgetPwdLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        LoginLayeredPane.add(forgetPwdLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 580, 90, 40));

        RegisterLayeredPane.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        head1.setBackground(new java.awt.Color(248, 249, 249));
        RegisterLayeredPane.setLayer(head1, javax.swing.JLayeredPane.PALETTE_LAYER);
        RegisterLayeredPane.add(head1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 820, 50));

        logo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_Flames.png"))); // NOI18N
        RegisterLayeredPane.setLayer(logo1, javax.swing.JLayeredPane.MODAL_LAYER);
        RegisterLayeredPane.add(logo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -2, 60, 50));

        loginTitle1.setFont(new java.awt.Font("微软雅黑", 1, 36)); // NOI18N
        loginTitle1.setForeground(new java.awt.Color(51, 51, 51));
        loginTitle1.setText("注册");
        RegisterLayeredPane.setLayer(loginTitle1, javax.swing.JLayeredPane.MODAL_LAYER);
        RegisterLayeredPane.add(loginTitle1, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 110, 90, 50));

        accountLabel1.setFont(new java.awt.Font("微软雅黑", 1, 24)); // NOI18N
        accountLabel1.setForeground(new java.awt.Color(51, 51, 51));
        accountLabel1.setText("账号");
        RegisterLayeredPane.setLayer(accountLabel1, javax.swing.JLayeredPane.MODAL_LAYER);
        RegisterLayeredPane.add(accountLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 190, 90, 50));

        registerAccountText.setFont(new java.awt.Font("微软雅黑", 0, 22)); // NOI18N
        RegisterLayeredPane.setLayer(registerAccountText, javax.swing.JLayeredPane.PALETTE_LAYER);
        RegisterLayeredPane.add(registerAccountText, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 240, 570, 60));

        pwdLabel1.setFont(new java.awt.Font("微软雅黑", 1, 24)); // NOI18N
        pwdLabel1.setForeground(new java.awt.Color(51, 51, 51));
        pwdLabel1.setText("密码");
        RegisterLayeredPane.setLayer(pwdLabel1, javax.swing.JLayeredPane.MODAL_LAYER);
        RegisterLayeredPane.add(pwdLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 330, 90, 50));

        registerPwdText.setFont(new java.awt.Font("微软雅黑", 0, 22)); // NOI18N
        RegisterLayeredPane.setLayer(registerPwdText, javax.swing.JLayeredPane.PALETTE_LAYER);
        RegisterLayeredPane.add(registerPwdText, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 380, 570, 60));

        registerBtn.setFont(new java.awt.Font("微软雅黑", 0, 24)); // NOI18N
        registerBtn.setForeground(new java.awt.Color(255, 255, 255));
        registerBtn.setText("注  册");
        registerBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                registerBtnMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                registerBtnMouseExited(evt);
            }
        });
        registerBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registerBtnActionPerformed(evt);
            }
        });
        RegisterLayeredPane.setLayer(registerBtn, javax.swing.JLayeredPane.PALETTE_LAYER);
        RegisterLayeredPane.add(registerBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 500, 570, 60));

        toLoginBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                toLoginBtnMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                toLoginBtnMouseExited(evt);
            }
        });
        toLoginBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toLoginBtnActionPerformed(evt);
            }
        });
        RegisterLayeredPane.setLayer(toLoginBtn, javax.swing.JLayeredPane.PALETTE_LAYER);
        RegisterLayeredPane.add(toLoginBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 580, 110, 40));

        toLoginLabel.setFont(new java.awt.Font("微软雅黑", 1, 18)); // NOI18N
        toLoginLabel.setForeground(new java.awt.Color(51, 51, 51));
        toLoginLabel.setText("返 回");
        RegisterLayeredPane.setLayer(toLoginLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        RegisterLayeredPane.add(toLoginLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 580, 50, 40));

        existButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_close.png"))); // NOI18N
        existButton.setAlignmentY(0.0F);
        existButton.setFocusPainted(false);
        existButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                existButtonMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                existButtonMouseExited(evt);
            }
        });
        existButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                existButtonActionPerformed(evt);
            }
        });

        BKG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/SecurityToolsPane/Security_Tools_BKG.png"))); // NOI18N
        BKG.setToolTipText("");
        BKG.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                BKGMouseDragged(evt);
            }
        });
        BKG.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                BKGMousePressed(evt);
            }
        });

        ShadowLayeredPane.setLayer(LoginLayeredPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
        ShadowLayeredPane.setLayer(RegisterLayeredPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
        ShadowLayeredPane.setLayer(existButton, javax.swing.JLayeredPane.PALETTE_LAYER);
        ShadowLayeredPane.setLayer(BKG, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout ShadowLayeredPaneLayout = new javax.swing.GroupLayout(ShadowLayeredPane);
        ShadowLayeredPane.setLayout(ShadowLayeredPaneLayout);
        ShadowLayeredPaneLayout.setHorizontalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(RegisterLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(LoginLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(ShadowLayeredPaneLayout.createSequentialGroup()
                                .addGap(753, 753, 753)
                                .addComponent(existButton, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(BKG, javax.swing.GroupLayout.PREFERRED_SIZE, 820, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE)))
        );
        ShadowLayeredPaneLayout.setVerticalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(RegisterLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(LoginLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(existButton)
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE)
                                        .addComponent(BKG, javax.swing.GroupLayout.PREFERRED_SIZE, 740, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(ShadowLayeredPane)
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(ShadowLayeredPane)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //切换退出按钮的样式
    private void toggleExistButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.red);
        }
    }

    // 切换普通按钮的样式
    private void toggleNormalButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.gray);
        }
    }

    // 切换普通按钮的样式
    private void togglePrimaryButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(ACTIVE_COLOR);
        }
    }


    // 供窗口拖拽用
    private void mainFrameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainFrameMousePressed
        pressedPoint = evt.getPoint();// 记录鼠标坐标
    }//GEN-LAST:event_mainFrameMousePressed

    // 供窗口拖拽用
    private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
        Point point = evt.getPoint();// 获取当前坐标
        Point locationPoint = getLocation();// 获取窗体坐标
        int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标
        int y = locationPoint.y + point.y - pressedPoint.y;
        setLocation(x, y);// 改变窗体位置,（按钮可以使用边界布局,也可以使用绝对布局）

    }//GEN-LAST:event_formMouseDragged

    // 退出按钮将触发该方法
    private void existButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_existButtonActionPerformed
//        System.exit(0);
        this.setVisible(false);
    }//GEN-LAST:event_existButtonActionPerformed

    // 退出按钮进入范围:触发样式
    private void existButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseEntered
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseEntered

    // 退出按钮退出范围:触发样式
    private void existButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseExited
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseExited

    // 供窗口拖拽用
    private void BKGMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BKGMousePressed
        mainFrameMousePressed(evt);
    }//GEN-LAST:event_BKGMousePressed

    // 供窗口拖拽用
    private void BKGMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BKGMouseDragged
        formMouseDragged(evt);
    }//GEN-LAST:event_BKGMouseDragged

    // 切换样式
    private void loginBtnMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_loginBtnMouseEntered
        loginBtn.setBackground(Colors.LOGIN_BTN_ACTIVE);
    }//GEN-LAST:event_loginBtnMouseEntered

    private void loginBtnMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_loginBtnMouseExited
        loginBtn.setBackground(Colors.LOGIN_BTN);
    }//GEN-LAST:event_loginBtnMouseExited

    // 切换样式
    private void toRegisterBtnMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toRegisterBtnMouseEntered
        toRegisterBtn.setBackground(Colors.REGISTER_BTN_ACTIVE);
    }//GEN-LAST:event_toRegisterBtnMouseEntered

    private void toRegisterBtnMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toRegisterBtnMouseExited
        toRegisterBtn.setBackground(Colors.REGISTER_BTN);
    }//GEN-LAST:event_toRegisterBtnMouseExited

    private void toRegisterBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toRegisterBtnActionPerformed
        // 登陆层关闭，注册层显示
        LoginLayeredPane.setVisible(false);
        LoginLayeredPane.setEnabled(false);
        RegisterLayeredPane.setVisible(true);
        RegisterLayeredPane.setEnabled(true);
        validate();
        repaint();
    }//GEN-LAST:event_toRegisterBtnActionPerformed

    private void registerBtnMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registerBtnMouseEntered

    }//GEN-LAST:event_registerBtnMouseEntered

    private void registerBtnMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_registerBtnMouseExited

    }//GEN-LAST:event_registerBtnMouseExited

    private void toLoginBtnMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toLoginBtnMouseEntered

    }//GEN-LAST:event_toLoginBtnMouseEntered

    private void toLoginBtnMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toLoginBtnMouseExited

    }//GEN-LAST:event_toLoginBtnMouseExited

    private void toLoginBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toLoginBtnActionPerformed
        // 登陆层显示，注册层隐藏
        RegisterLayeredPane.setVisible(false);
        RegisterLayeredPane.setEnabled(false);
        LoginLayeredPane.setVisible(true);
        LoginLayeredPane.setEnabled(true);
        validate();
        repaint();
    }//GEN-LAST:event_toLoginBtnActionPerformed

    private void loginBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginBtnActionPerformed
        // 账号密码识别，弹框显示
        if (accountText.getText().equals("admin") && pwdText.getText().equals("123")) {
            new PopConfirmDialog(this, true, "登陆成功", 1).setVisible(true);
        } else {
            new PopConfirmDialog(this, true, "<html>您输入的账号或密码不正确, 请重新输入</html>", 0).setVisible(true);
        }

    }//GEN-LAST:event_loginBtnActionPerformed

    private void pwdTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pwdTextKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            loginBtnActionPerformed(null);
        }
    }//GEN-LAST:event_pwdTextKeyPressed

    private void registerBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerBtnActionPerformed
        // 如果账号或者密码为空, 抛出错误提示
        if (registerAccountText.getText() == null || registerPwdText.getText() == null || registerAccountText.getText().trim().equals("") || registerPwdText.getText().trim().equals("")) {
            new PopConfirmDialog(this, true, "<html>账号或密码为空, 请重新输入</html>", 0).setVisible(true);
            return;
        }
        String pwd = registerPwdText.getText().trim();
        // 输入的密码如果小于6位数, 抛出警告提示
        if (pwd.length() < 6) {
            new PopConfirmDialog(this, true, "<html>输入密码格式有误<br/>输入的密码位数必须大于6位数!</html>", 2).setVisible(true);
        } else {
            new PopConfirmDialog(this, true, "注册成功", 1).setVisible(true);
        }
    }//GEN-LAST:event_registerBtnActionPerformed


    public void activeLabelStyle(javax.swing.JLabel label, javax.swing.JLabel image, String imgURL) {
        label.setForeground(ACTIVE_COLOR);
        image.setIcon(new javax.swing.ImageIcon(getClass().getResource(imgURL)));
    }

    public void closeActiveLabelStyle(javax.swing.JLabel label, javax.swing.JLabel image, String imgURL) {
        label.setForeground(NORMAL_COLOR);
        image.setIcon(new javax.swing.ImageIcon(getClass().getResource(imgURL)));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Login.runInstance();
            }
        });
    }

    public static Login login;

    public static void runInstance() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (login == null) {
                    login = new Login();
                }
                login.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel BKG;
    private javax.swing.JLayeredPane LoginLayeredPane;
    private javax.swing.JLayeredPane RegisterLayeredPane;
    private javax.swing.JLayeredPane ShadowLayeredPane;
    private javax.swing.JLabel accountLabel;
    private javax.swing.JLabel accountLabel1;
    private javax.swing.JTextField accountText;
    private javax.swing.JButton existButton;
    private javax.swing.JLabel forgetPwdLabel;
    private javax.swing.JLabel head;
    private javax.swing.JLabel head1;
    private javax.swing.JButton loginBtn;
    private javax.swing.JLabel loginTitle;
    private javax.swing.JLabel loginTitle1;
    private javax.swing.JLabel logo;
    private javax.swing.JLabel logo1;
    private javax.swing.JLabel pwdLabel;
    private javax.swing.JLabel pwdLabel1;
    private javax.swing.JPasswordField pwdText;
    private javax.swing.JTextField registerAccountText;
    private javax.swing.JButton registerBtn;
    private javax.swing.JPasswordField registerPwdText;
    private javax.swing.JButton toLoginBtn;
    private javax.swing.JLabel toLoginLabel;
    private javax.swing.JButton toRegisterBtn;
    private javax.swing.JLabel toRegisterLabel;
    // End of variables declaration//GEN-END:variables
}


